Delete DxlAttr and Views

Hello,

I'm trying to delete all DXL ATTR and their views list within a Skip List does anyone see any logic issues with my code? Thank you.

-Jim


EHcnck - Tue Dec 10 23:16:59 EST 2013

Re: Delete DxlAttr and Views
Mathias Mamsch - Wed Dec 11 07:13:07 EST 2013

A very common problem, that you have in your code, is that you deleting from a module, while iterating over it:

for vn in views mod do {
   ...
   err = delete(mod, view vn)
}

for at in mod do {
   ...
   err = delete(mod, at) //Delete custom attr listed in Skip List
}

Dont do that. Put the attribute types at / view names to delete in a skip list and issue

for at in skipToDelete do delete (mod, at)

You did not mention the problem you have with your code, but commonly it happens that some deletions are not performed correctly. Also when deleting stuff from a module it makes sense to call flushDeletions() sometimes although I do not know if that applys to attribute types / views ...

Since you already have the names of the types/ views in your skip you can simplify your code:

for typename in skipToDelete do {
    AttrType at = find (mod, typename);
    if (!null at) delete at;
}

Maybe that helps, regards, Mathias